package org.ntu.csn.doraemon.model;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Date;

import org.ntu.csn.doraemon.data.Serializable;

public class Mark implements Serializable{
	
	int id;
	
	String name;
	
	int mark;
	
	String time;
	
	

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getMark() {
		return mark;
	}

	public void setMark(int mark) {
		this.mark = mark;
	}
	

	public String getTime() {
		return time;
	}

	public void setTime(String time) {
		this.time = time;
	}

	public byte[] serialize() throws IOException {
	ByteArrayOutputStream bos = new ByteArrayOutputStream();
	DataOutputStream dos = new DataOutputStream(bos);
	dos.writeUTF(this.getName());
	dos.writeInt(this.getMark());
	dos.writeUTF(this.getTime());
	
		
		return bos.toByteArray();
	}

	public void unSerialize(byte[] data) throws IOException {
		ByteArrayInputStream bis = new ByteArrayInputStream(data);
		DataInputStream dis = new DataInputStream(bis);
	
		this.setName(dis.readUTF());
		this.setMark(dis.readInt());
		this.setTime(dis.readUTF());
	
		
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}


	
	
	

}
